module.exports = (sequelize, DataTypes) => {
  const token = sequelize.define('token', {
    idType: DataTypes.STRING(15),
    // uuId: DataTypes.STRING(70),
    identityType: DataTypes.STRING(15),
    token: DataTypes.STRING(150),
    loginTime: DataTypes.DATE,
    outdateTime: DataTypes.DATE,
    device: DataTypes.STRING(150),
    ip: DataTypes.STRING(50)
    // email: DataTypes.STRING(50),
    // password: DataTypes.STRING(50),
    // token: DataTypes.STRING(50),
  })

  token.associate = (models) => {
    token.belongsTo(models.shop, {
      foreignKey: 'uuId',
      targetKey: 'shopId',
      as: 'shop'
    })
    token.belongsTo(models.user, {
      foreignKey: 'uuId',
      targetKey: 'userId',
      as: 'user'
    })
  }
  return token
}
